package pl.gettoknowme.mobile.android.services.calls;

import android.provider.CallLog;
import android.util.Log;

/**
 * Pojedynczy element historii połączeń
 * @author Michał Kołodziejski
 */
public class CallLogEntry {
    
    public static enum CallType {
        INCOMING,
        OUTGOING,
        MISSED,
        UNKNOWN;
        
        public static CallType forInt(int callTypeId){
            switch (callTypeId) {
            case CallLog.Calls.INCOMING_TYPE:
                return INCOMING;
            case CallLog.Calls.OUTGOING_TYPE:
                return OUTGOING;
            case CallLog.Calls.MISSED_TYPE:
                return MISSED;
            default:
                Log.w(CallType.class.getName(), "No such CallType: "+callTypeId);
                return UNKNOWN;
            }
        }
    }
    
    protected CallType callType;
    protected long seconds;
    protected String number;
    protected long timestamp;
    
    public CallLogEntry() {
    }

    public CallType getCallType() {
        return callType;
    }

    public void setCallType(CallType callType) {
        this.callType = callType;
    }

    public long getSeconds() {
        return seconds;
    }

    public void setSeconds(long seconds) {
        this.seconds = seconds;
    }

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public long getTimestamp() {
        return timestamp;
    }

    public void setTimestamp(long timestamp) {
        this.timestamp = timestamp;
    }
    
    
    @Override
    public String toString() {
        return "CallLogEntry["
            + "number: " + number
            + ", seconds: " + seconds
            + ", callType: " + callType.toString()
            + ", timestamp: " + timestamp
            + "]";
    }
}
